// var bb=request.getParameter("name")
// console.log(bb)
// $(function geturl(){
//     var searchURL = window.location.search;  
//     searchURL = searchURL.substring(1, searchURL.length);  
//     var targetPageId = searchURL.split("&")[0].split("=")[1];
//     var targetPageId  = searchURL.split("&")[1].split("=")[1];
//     var namemm=decodeURIComponent(targetPageName)
//     alert(namemm)
//     return(targetPageId ,targetPageId )
// })

$(function () {
    var searchURL = window.location.search;  
    searchURL = searchURL.substring(1, searchURL.length);  
    var targetPageId = searchURL.split("&")[0].split("=")[1];
    var targetPageName  = searchURL.split("&")[1].split("=")[1];
    var namemm=decodeURIComponent(targetPageName)
    document.getElementById('sidebartitle').innerHTML=namemm
        
    $.get('api/menu/getmenubypid',{id:targetPageId},function (data) {
        console.log(data);        
        //1.getJSON方法获取json文件数据，data为json存储的数据对象组
        for (var i = 0; i < data.length; i++) {
            // if (data[i].ParentId == null) {
            //     //5.判断非一级菜单项
            //     //根据该对象的父级菜单id找li标签，成为其子菜单项
            //     $("#sidebar").append("<h3 " + data[i]["Name"] + "</h3>");
            // }
            //2.循环访问data数组中的每个对象，长度为data.length               
                if (data[i].ParentId != null) {
                    //4.判断该data对象是否菜单的父级菜单id为0
                    //为0 则为一级菜单，生成li标签，显示菜单项名称data[i]["name"]
                    //同时添加li的class为data[i]["id"]
                    $("#sidebarmenu").append("<li class='" + data[i]["Id"] + "'><a id='" + data[i]["Id"] + "' href=# onclick=DealFun2(this.id);>" + data[i]["Name"] + "</a><ul></ul></li>");                
                                                   
                }                
        };
    })

  
});
function DealFun2(Id) 
 {          
    $.get('api/menu/getmenubypid',{id:Id},function (data) {
        console.log(data)
        for (var i = 0; i < data.length; i++) {
        
        if (data[i]["Id"] == Id) {
            if(data[i]["Template"]=="1"){
                var templateurl='services.html'      
            } 
            if(data[i]["Template"]=="2"){
                var templateurl='rates.html'      
            } 
            var trName=document.getElementById(data[i]["ParentId"]).innerText;
                var trId = templateurl + '?menuid=' + Id + '&name=' + trName;         
                open(trId,'_self')       
        }
    }})
   
    console.log(trId);    
   }
